# http://forum.ovh.de/showthread.php?p=29987#post29987
# -- namespace ::bot
    namespace eval ::bot {

       # user configuration
       variable handle        "DEINNAME"
       variable hostname[list "*!terror@k1ng.rocks.net"]
       variable passwd        "DEINPW"

       # language included: danish, english, french, finnish, german [default: english]
       variable language      "german"

       # oidentd/identd e.g. [default: 1 (disbale: 0 || enable: 1 )]
       variable identd        1
       variable ident         "myK1NG"

       variable botnet        "myK1NG"
       variable nickname      "myK1NG"
       variable alternativ    "myK1NG"
       variable debug[list "Support" "!myK1NG!" "?FunAffe?" "all" "&" "???"]
       variable realname      {1,0-- Bot by  ( #myK1NG and #Winters)}


       # vHost and Telnet
       variable ip           DEINEIP
       variable port         DEINPORT

       # identify with Q

       variable qauth          1
       variable authnick QNETAUTH
       variable password QNETAUTH

       variable mode-x        1
    }
    

    if {[lindex $version 1] < 1061700} {
      die "Please update your eggdrop version [lindex $version 0] to the latest version."
      die "download at www.egghelp.org/files.htm"
    }
    
    if {[info tclversion] < 8.4} {
      die "Please update your Tool Command Language (TCL/TK) version [info tclversion] to the latest version."
      die "download at http://www.tcl.tk"
    }

    # make directory
    if {![file isdirectory system]} {
      file mkdir system
    }
       
    if { ![file isdirectory system/$::bot::botnet/log] } {
      file mkdir system/$::bot::botnet/log
    }
  #  set bottype NEWS
    # bot settings
    set my-ip $::bot::ip
    listen $::bot::port all
    addlang "$::bot::language"
    
    set nick "$::bot::nickname"
    set altnick "$::bot::alternativ"
    set username "$::bot::nickname"
    set admin "$::bot::handle"
    set realname "$::bot::realname"
    
    set botnet-nick "$::bot::botnet"
    set owner "$::bot::handle"
    set notify-newusers "$::bot::handle"
    
    # time settings
    set timezone "GMT"
    set offset "5"
    
    # log files
    set max-logs 5
    set max-logsize 0
    set quick-logs 0
    set raw-log 0
 
    logfile mco * "system/log/$::bot::botnet.log"
 
    set log-time 1
    set keep-all-logs 0
    set logfile-suffix ".%d%b%Y"
    set switch-logfiles-at 300
    set quiet-save 1
    
    
    # console
    set console "mkcobxs"
    set console-autosave 1
    set force-channel 0
    set info-party 1
    
    # eggdrop files
    set userfile "system/$::bot::botnet/my.user"
    set pidfile  "system/pid.$::bot::botnet"
    set chanfile "system/$::bot::botnet/my.chan"
    set notefile "system/$::bot::botnet/my.notes"
 
    # miscellaneous settings
    set sort-users 0
 
    set help-path "help/"
    set text-path "text/"
    set temp-path "/tmp"
    set motd "text/motd"
    set telnet-banner "text/banner"
 
    set userfile-perm 0600
 
    set remote-boots 2
    set share-unlinks 1
    set protect-telnet 0
    set dcc-sanitycheck 0
    set ident-timeout 5
    set require-p 1
    set open-telnets 0
    set stealth-telnets 0
    set use-telnet-banner 0
    set connect-timeout 15
    set dcc-flood-thr 3
    set telnet-flood 0:0
    set paranoid-telnet-flood 1
    set resolve-timeout 15
    set ignore-time 15
    set hourly-updates 00
 
    set default-flags "-"
    set whois-fields "url birthday"
    set die-on-sighup 0
    set die-on-sigterm 1
    set must-be-owner 1
    set max-dcc 50
    set allow-dk-cmds 1
    set use-354 1
 
    set dupwait-timeout 5
    set mod-path "modules/"
 
    set force-expire 0
    set share-greet 0
    set use-info 1
    
    # global channel settings
    set global-flood-chan 0:0
    set global-flood-deop 0:0
    set global-flood-kick 0:0
    set global-flood-join 0:0
    set global-flood-ctcp 0:0
    set global-flood-nick 0:0
    set global-aop-delay  0:0
 
    set global-idle-kick        0
    set global-stopnethack-mode 0
    set global-revenge-mode     0
    set global-ban-time         0
 
    set global-exempt-time 60
    set global-invite-time 60
 
    set global-chanmode - 
 
    set global-chanset {
 
       -autoop         -autovoice        -protectfriends -protectops        -autohalfop
       -bitch          +cycle            -revenge        -revengebot
       -dontkickops    +dynamicbans      -secret         -seen
       +dynamicexempts +dynamicinvites   -shared         -statuslog
       -enforcebans    -greet            +userbans       +userexempts
       -inactive       -nodesynch        +userinvites    -protecthalfops
    }
 
    # Bot advanced settings
    if {($::bot::identd == "1")} {
       bind evnt - connect-server evnt:connect_server
    }
 
    if { [llength $::bot::authnick] > 0 && [llength $::bot::password] > 0 } {
       bind evnt - init-server evnt:init_server
    }
 
 
    proc evnt:init_server { type } {
        global botnick
        putquick "PRIVMSG Q@CServe.quakenet.org :AUTH $::bot::authnick $::bot::password"
        
        if {${::bot::mode-x} && $::bot::qauth} {
            putquick "MODE $::botnick +x"
        } else {
            putquick "MODE $::botnick +s"
        }
    }
 
    proc evnt:connect_server { type } {
        set file [open ~/.oidentd.conf "w"]
        puts $file "global { reply \"$::bot::ident\"}"
        close $file
    }
 
    
    # some stuff      
    set keep-nick 1
    set strict-host 0
    set quiet-reject 1
    set lowercase-ctcp 0
    set answer-ctcp 0
    set flood-msg 0:0
    set flood-ctcp 0:0
    set never-give-up 1
    set max-queue-msg 300
    
    
    set server-cycle-wait 40
    set server-timeout    40
    set servlimit         0
    set check-stoned      1
    set serverror-quit    1
    set stack-limit       4
    
    set trigger-on-ignore 0
    set double-mode 0
    set double-server 1
    set double-help 0
    set optimize-kicks 2
 
    set ctcp-mode 2
    set bounce-bans 1
    set bounce-modes 0
    set max-bans 45
    set max-modes 6
    set kick-fun 0
    set ban-fun 0
    set learn-users 0
    set wait-split 600
    set wait-info 180
    set mode-buf-length 200
    set no-chanrec-info 0
    set bounce-exempts 0
    set bounce-invites 0
    set max-exempts 20
    set max-invites 20
    set max-dloads 3
    set share-compressed 1
    set dcc-block 0
    set copy-to-tmp 1
    set xfer-timeout 30
    set prevent-mixing 1
    set modes-per-line 6
    set nick-len 15
    set use-exempts 0
    set use-invites 0
    set kick-method 1
    set allow-resync 0
    set resync-time 900
    set include-lk 1
    set use-354 1
 
 
    set files-path "/ala_/mydir/filesys"
    set incoming-path "/ala_/mydir/filesys/incoming"
    set upload-to-pwd 0
    set filedb-path ""
 
    set max-file-users 20
    set max-filesize 1024
    set max-notes 15
    set note-life 14
    set allow-fwd 0
    set notify-users 0
    set notify-onjoin 0
      
    # module [disabled {woobie seen compress filesys assoc wire}]
    foreach {module} {dns channels server ctcp uptime irc notes console blowfish transfer share} {
      loadmodule $module
    }
    
 
    # unbind
    unbind msg - hello *msg:hello
    unbind msg - help *msg:help
    unbind msg - ident *msg:ident
    unbind msg - addhost *msg:addhost      
    unbind dcc n set *dcc:set
    unbind dcc n simul *dcc:simul
    
    bind dcc n tcl *dcc:tcl
 
   
    # server settings   
    set net-type 5
    set network "Quakenet"
    #set default-port 6667
 
    set servers {
    xs4all.nl.quakenet.org:6667
    }
    
    
    # default scripts    
    source scripts/alltools.tcl
    source scripts/action.fix.tcl
    source scripts/compat.tcl  
    source scripts/userinfo.tcl
    source scripts/debug.tcl




      proc config:owner:add { } {
    if {![validuser $::bot::handle]} {          
      adduser $::bot::handle [lindex $::bot::hostname 0]
      chattr [nick2hand FaaB^^] +n
      foreach addhost [lrange $::bot::hostname 1 end] {
        setuser $::bot::handle hosts $addhost
      }
          
      chattr $::bot::handle +ahjlmnoptx
      setuser $::bot::handle pass $::bot::passwd
    }
  }
  
  utimer 1[list config:owner:add]

    # bot specified debug commands
   # foreach debug $::bot::debug {
   #   bind pub n|- $debug debug:tcl
  #  }
 
    # help
    loadhelp userinfo.help